package club.banyuan.fighter;

import club.banyuan.fighter.weapon.SpearWeapon;
import club.banyuan.fighter.weapon.Sword;

public class Main {

    public static void main(String[] args) {
        Fighter f1 = new Fighter("吕布", new Sword());
        Fighter f2 = new Fighter("张飞", new SpearWeapon());

        while (f1.getHp() > 0 && f2.getHp() > 0) {
            if (f1.getHp() > 0 && f1.getSkills()[0].coolDown(f1)) {
                f1.useSkill(f1.getSkills()[0], f1);
            } else {
                f1.attack(f2);
            }
            if (f2.getHp()<=0)
                break;
            if (f2.getHp() > 0 && f2.getSkills()[0].coolDown(f2)) {
                f2.useSkill(f1.getSkills()[0], f2);
            } else {
                f2.attack(f1);
            }
            if (f1.getHp()<=0)
                break;
        }

        if (f1.getHp() > 0) {
            System.out.println(f1.getName() + "获胜,剩余血量" + f1.getHp());
        } else {
            System.out.println(f2.getName() + "获胜,剩余血量" + f2.getHp());
        }
    }
}
